package org.example.yunshu.demos.controller;

import org.example.yunshu.demos.constant.Constants;
import org.example.yunshu.demos.model.Friend;
import org.example.yunshu.demos.model.UserInfo;
import org.example.yunshu.demos.service.SessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/session")
public class SessionController {
    @Autowired
    private SessionService sessionService;

    @RequestMapping("/getSessionListByUserId")
    public Object getSessionListByUserId(HttpSession httpSession){
        return sessionService.getSessionList(httpSession) ;
    }
    @Transactional(rollbackFor = Exception.class)
    @RequestMapping("/createSession")
    public Object createSession(Friend friend , HttpSession httpSession){
        return sessionService.createSession(friend , httpSession);
    }
}
